package net.huashitong.scheduling.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sirdc.modules.core.dao.BaseDao;
import com.sirdc.modules.sys.base.StringPKService;
import com.sirdc.modules.utils.ObjectUtils;

import net.huashitong.Indicators.filter.IndicatorBreakdownFilter;
import net.huashitong.scheduling.dao.FinanceRevenueDao;
import net.huashitong.scheduling.entity.FinanceRevenue;
import net.huashitong.scheduling.web.RevenueController;
@Service
public class FinanceRevenueService extends StringPKService<FinanceRevenue>{
	@Autowired
	private FinanceRevenueDao dao;
	public static final String[] months = {"12","11","10","09","08","07","06","05","04","03","02","01"};
	public static final String[] years={"2018","2017"};
	@Override
	protected BaseDao<FinanceRevenue, String> getDao(){
		return dao;
	}
	public List<FinanceRevenue> queryByindustryName(IndicatorBreakdownFilter filter){
		return dao.queryByindustryName(filter);
	}
	 public List<FinanceRevenue> queryByDate(String currentMonth){
		 return dao.queryByDate(currentMonth);
	 }
	 
	 public List<Map<String, Object>>  queryFinancialMainIndexAssess(){
		 List<Map<String, Object>> FinancialMainIndexAssess = new ArrayList<>();
		 List<FinanceRevenue> fList=new ArrayList<FinanceRevenue>();
		 for(int j=0;j<FinanceRevenueService.years.length;j++){
		  	   for(int i=0; i<FinanceRevenueService.months.length;i++){
		  		 fList=dao.queryByDate(years[j]+months[i]);
		  		 if(ObjectUtils.isNotBlank(fList)){
			  			
			  			break;
			  		 }
		  	   }
		 }
		 for(FinanceRevenue fr:fList){
			 Map<String, Object> map1 = new HashMap<String, Object>();
			 map1.put("industryName", fr.getIndustryName());
			 map1.put("predictName", fr.getPredictName());
			 map1.put("predictValue", fr.getPredictValue());
			 map1.put("accumulativeName", fr.getAccumulativeName());
			 map1.put("accumulativeValue", fr.getAccumulativeValue());
			 map1.put("schedule", fr.getSchedule());
			 map1.put("scheduleName", fr.getScheduleName());
			 map1.put("ranking", fr.getRanking());
			 map1.put("unit", fr.getUnit());
			 FinancialMainIndexAssess.add(map1);
		  }
		 return FinancialMainIndexAssess;
	 }
}
